//
//  rect_3d.hpp
//  OpenLearn
//
//  Created by korion chen on 2020/3/27.
//  Copyright © 2020 korion. All rights reserved.
//

#ifndef rect_3d_hpp
#define rect_3d_hpp

#include <stdint.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

class Rect3D {
    static const float vertices[20];
    
    static const int indices[6];
    
    static const char *vertex_shader_code;
    
    static const char *fragment_shader_code;
    
    uint32_t mProgram;
    
    uint32_t texture0;
    
    uint32_t texture1;
    
    uint32_t context;
    
    uint32_t verticesBuffer;
    
    uint32_t indicesBuffer;

    glm::mat4 model;
    
    glm::mat4 view;
    
    glm::mat4 projection;
    
    int width;
    
    int height;
    
    bool hasInit;
    
    int createShader(int type, const char* code);
    
    int createProgram();
    
    int loadTexture(const char* path, bool reverseY);
    
    
public:
    
    bool init(int, int);
    
    void drawSelf(GLFWwindow*, float, float);
    
    void destroy();
    
};


#endif /* rect_3d_hpp */
